import { reqCategory1, reqCategory2, reqCategory3 } from "@/api/product/attr";
import type { categoryResponseData } from "@/api/product/attr/model";
import { defineStore } from "pinia";
import { ref } from "vue";

export const useCategoryStore = defineStore("category", () => {
  let c1Arr: any = ref([]);
  let c2Arr: any = ref([]);
  let c3Arr: any = ref([]);

  let c1Id: any = ref("");
  let c2Id: any = ref("");
  let c3Id: any = ref("");
  let getCategory1List = async () => {
    let result: categoryResponseData = await reqCategory1();
    c1Arr.value = result;
  };

  let getCategory2List = async () => {
    let result: categoryResponseData = await reqCategory2(c1Id.value);
    c2Arr.value = result;
  };
  let getCategory3List = async () => {
    let result: categoryResponseData = await reqCategory3(c2Id.value);
    c3Arr.value = result;
  };
  return {
    c1Arr,
    getCategory1List,
    c1Id,
    c2Arr,
    getCategory2List,
    c2Id,
    c3Arr,
    getCategory3List,
    c3Id,
  };
});
